using UnityEngine;
using System.Collections;

//change speed according
public class PositionByValueOnUpdate : CharacterAction
{
	public float forward = 0;
    public float up = 0;
    public float right = 0;

    protected float forwardSpeed;
    protected float upSpeed;
    protected float rightdSpeed;
   
    private Vector3 speed;
    public override void OnActionEnter(Character character)
    {
        base.OnActionEnter(character);
        forwardSpeed = forward/character.curState.duration;
        upSpeed = up/character.curState.duration;
        rightdSpeed = right/character.curState.duration;

        Debug.LogError("forwardSpeed = "+ forwardSpeed);
        Debug.LogError("upSpeed = "+ upSpeed);
        Debug.LogError("rightdSpeed = "+ rightdSpeed);

        Vector3 velocityZ = character.transformRef.forward;
        Vector3 velocityY = character.transformRef.up;
        Vector3 velocityX = character.transformRef.right;

        velocityZ *= forwardSpeed;
        velocityY *= upSpeed;
        velocityX *= rightdSpeed;
        
        speed = velocityZ + velocityY + velocityX;
    }

    public override void OnFrameUpdate (Character.FrameUpdate arg)
    {
        Character character = arg.character;
        character.rigidbodyRef.velocity = speed;
    }
}

